
package com.hmsg.health.dao;

import com.hmsg.health.bean.Dto.AppealDto;
import com.hmsg.health.bean.domain.AppealDo;
import com.hmsg.health.bean.domain.BannerDo;
import com.hmsg.health.bean.domain.SorderDo;
import com.hmsg.health.bean.domain.TaskDo;
import com.hmsg.health.bean.domain.UserDo;

import java.util.Date;
import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.One;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface OrderDao {
	
    @Select("select * from s_order where id=#{id}")
    SorderDo findOne(@Param("id")Integer id);
    
    
    @Select("<script>" +
    	    "select * from  `s_order` where 1=1 " +
    	    "    <if test='info.id != null'>" +
    	    "     and `id` = #{info.id} " +
    	    "    </if>" +
    	
    	    "    <if test='info.status != null'>" +
    	    "    and  `status` = #{info.status} " +
    	    "    </if>" +
    	    "    <if test='info.orderNum != null'>" +
    	    "    and  `order_num` = #{info.orderNum} " +
    	    "    </if>" +
    	    "    <if test='info.userId != null'>" +
    	    "    and  `user_id` = #{info.userId} " +
    	    "    </if>" +
    	   
    	    "</script>")
    List<SorderDo> select(@Param("info") SorderDo info);
  
  
    @Insert("<script>" +
    "insert into `s_order` " +
    "  <set>" +
    "    <if test='info.userId != null'>" +
    "     `user_id` = #{info.userId}, " +
    "    </if>" +
    "    <if test='info.status != null'>" +
    "      `status` = #{info.status}, " +
    "    </if>" +
    "    <if test='info.createTime != null'>" +
    "      `create_time` = #{info.createTime}," +
    "    </if>" +
    "    <if test='info.gloadCount != null'>" +
    "      `gload_count` = #{info.gloadCount}," +
    "    </if>" +
    "    <if test='info.goodsId != null'>" +
    "      `goods_id` = #{info.goodsId}," +
    "    </if>" +
    "    <if test='info.payTime != null'>" +
    "      `pay_time` = #{info.payTime}," +
    "    </if>" +
    "    <if test='info.amount != null'>" +
    "      `amount` = #{info.amount}," +
    "    </if>" +
    "    <if test='info.orderNum != null'>" +
    "      `order_num` = #{info.orderNum}" +
    "    </if>" +
    
    "  </set>" +
    "</script>")
	@Options(useGeneratedKeys = true, keyProperty = "id")
	int save(@Param("info") SorderDo info);


    @Update({"<script>",
		"UPDATE  s_order",
		"<trim prefix='set' suffixOverrides=','>",
		
		"<if test='user.status!=null'>",
		"status= #{user.status}",
		"</if>",
		"<if test='user.payTime!=null'>",
		"pay_time= #{user.payTime}",
		"</if>",
		"</trim>",
		"where id = #{user.id}",
		"</script>"})
	@Options(useGeneratedKeys = true, keyProperty = "id")
 	Integer update(@Param("user") SorderDo user);


}